import 'package:kepu/generated/json/base/json_convert_content.dart';
import 'package:kepu/model/plant_type_entity.dart';

PlantTypeEntity $PlantTypeEntityFromJson(Map<String, dynamic> json) {
  final PlantTypeEntity plantTypeEntity = PlantTypeEntity();
  final int? code = jsonConvert.convert<int>(json['code']);
  if (code != null) {
    plantTypeEntity.code = code;
  }
  final String? msg = jsonConvert.convert<String>(json['msg']);
  if (msg != null) {
    plantTypeEntity.msg = msg;
  }
  final List<PlantTypeData>? data = (json['data'] as List<dynamic>?)
      ?.map(
          (e) => jsonConvert.convert<PlantTypeData>(e) as PlantTypeData)
      .toList();
  if (data != null) {
    plantTypeEntity.data = data;
  }
  return plantTypeEntity;
}

Map<String, dynamic> $PlantTypeEntityToJson(PlantTypeEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['code'] = entity.code;
  data['msg'] = entity.msg;
  data['data'] = entity.data.map((v) => v.toJson()).toList();
  return data;
}

extension PlantTypeEntityExtension on PlantTypeEntity {
  PlantTypeEntity copyWith({
    int? code,
    String? msg,
    List<PlantTypeData>? data,
  }) {
    return PlantTypeEntity()
      ..code = code ?? this.code
      ..msg = msg ?? this.msg
      ..data = data ?? this.data;
  }
}

PlantTypeData $PlantTypeDataFromJson(Map<String, dynamic> json) {
  final PlantTypeData plantTypeData = PlantTypeData();
  final int? planttypeId = jsonConvert.convert<int>(json['planttypeId']);
  if (planttypeId != null) {
    plantTypeData.planttypeId = planttypeId;
  }
  final String? planttypeContent = jsonConvert.convert<String>(
      json['planttypeContent']);
  if (planttypeContent != null) {
    plantTypeData.planttypeContent = planttypeContent;
  }
  return plantTypeData;
}

Map<String, dynamic> $PlantTypeDataToJson(PlantTypeData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['planttypeId'] = entity.planttypeId;
  data['planttypeContent'] = entity.planttypeContent;
  return data;
}

extension PlantTypeDataExtension on PlantTypeData {
  PlantTypeData copyWith({
    int? planttypeId,
    String? planttypeContent,
  }) {
    return PlantTypeData()
      ..planttypeId = planttypeId ?? this.planttypeId
      ..planttypeContent = planttypeContent ?? this.planttypeContent;
  }
}